package com.sgb.kjwl.view.ui.activity.transport.driver.trans;

import android.content.Context;
import android.content.Intent;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityTransTransListBinding;
import com.sgb.kjwl.di.transport.DaggerTransportComponent;
import com.sgb.kjwl.di.transport.TransportModule;
import com.sgb.kjwl.view.ui.activity.transport.driver.price.PriceItemEntity;
import com.sgb.kjwl.view.ui.activity.transport.driver.price.PriceListAdapter;
import com.sgb.kjwl.view.ui.activity.transport.driver.price.PriceListModel;
import com.swgk.core.base.di.AppComponent;

import java.util.List;

import javax.inject.Inject;

/**
 * Created by harisucici on 2020/4/7
 * Class description:货源列表
 */
public class TransListActivity extends AppActivity {

    @Inject
    PriceListModel priceListModel;
    private PriceListAdapter adapter;
    private ActivityTransTransListBinding binding;


    public static void start(Context context) {
        Intent intent = new Intent();
        intent.setClass(context, TransListActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerTransportComponent
                .builder()
                .appComponent(appComponent)
                .transportModule(new TransportModule(this))
                .build()
                .inject(this);
    }

    @Override
    protected void initView() {
        binding = DataBindingUtil.setContentView(this, R.layout.activity_trans_trans_list);
        binding.include.ivBack.setOnClickListener(view -> onBackPressed());
        binding.include.titleView.setText("承运管理");
        binding.list.setLayoutManager(
                new LinearLayoutManager(this,
                        LinearLayoutManager.VERTICAL, false));
        adapter = new PriceListAdapter(this, (binding, taskBean, i) -> {

        }
        );
        binding.list.setAdapter(adapter);
        binding.setLifecycleOwner(this);

    }


    private void setData(List<PriceItemEntity> entities) {
        adapter.refreshData(entities);
    }


    @Override
    protected void init() {
//        detailModel.getCarsInfoDetail();
    }

//    public void getCarsInfoDetail(CarsInfoDetailEntity3 entity) {
//
//        binding.setViewModel(entity);
//
//        String url = "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=4002707394,2738740472&fm=11&gp=0.jpg";
//        RequestOptions options = new RequestOptions()
//                .centerCrop();
//        Glide.with(CarsInfoDetailActivity3.this).asBitmap().apply(options).load(url).into(binding.carImg);
//
//        List<CarsInfoDetailEntity3> list = new ArrayList<>();
//        for (int i = 0; i < 10; i++) {
//            CarsInfoDetailEntity3 e = new CarsInfoDetailEntity3();
//            e.setCurrentLocation("北京朝阳区启浩大厦_" + i + "号");
//            e.setToLocation("上海浦东新区东方明珠大厦_" + i + "号");
//            list.add(e);
//        }
//
//        adapter.setDatas(list);
//    }
}
